﻿// Copyright (c)  MOKEYISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using NSQL.Expressions;
using NSQL.Expressions.Functions;

namespace NSQL.Extensions
{

    public static class DateTimeExpressionExtensions
    {
        public static AddIntervalFunction AddYears(this IDateTimeExpression dateTime, int years)
        {
            return new AddIntervalFunction(dateTime, IntervalExpression.FromYears(years));
        }
        public static AddIntervalFunction AddMonths(this IDateTimeExpression dateTime, int months)
        {
            return new AddIntervalFunction(dateTime, IntervalExpression.FromMonths(months));
        }
        public static AddIntervalFunction AddDays(this IDateTimeExpression dateTime, int days)
        {
            return new AddIntervalFunction(dateTime, IntervalExpression.FromDays(days));
        }
        public static AddIntervalFunction AddHours(this IDateTimeExpression dateTime, int hours)
        {
            return new AddIntervalFunction(dateTime, IntervalExpression.FromHours(hours));
        }
        public static AddIntervalFunction AddMinutes(this IDateTimeExpression dateTime, int minutes)
        {
            return new AddIntervalFunction(dateTime,IntervalExpression.FromMinutes(minutes));
        }
        public static AddIntervalFunction AddSeconds(this IDateTimeExpression dateTime, int seconds)
        {
            return new AddIntervalFunction(dateTime, IntervalExpression.FromSeconds(seconds));
        }

        public static ExtractFunction GetYear(this IDateTimeExpression dateTime)
        {
            return new ExtractFunction(dateTime, ExtractType.Year);
        }
        public static ExtractFunction GetMonth(this IDateTimeExpression dateTime)
        {
            return new ExtractFunction(dateTime, ExtractType.Month);
        }
        public static ExtractFunction GetWeek(this IDateTimeExpression dateTime)
        {
            return new ExtractFunction(dateTime, ExtractType.Week);
        }
        public static ExtractFunction GetDay(this IDateTimeExpression dateTime)
        {
            return new ExtractFunction(dateTime, ExtractType.Day);
        }
        public static ExtractFunction GetHour(this IDateTimeExpression dateTime)
        {
            return new ExtractFunction(dateTime, ExtractType.Hour);
        }
        public static ExtractFunction GetMinute(this IDateTimeExpression dateTime)
        {
            return new ExtractFunction(dateTime, ExtractType.Minute);
        }
        public static ExtractFunction GetSecond(this IDateTimeExpression dateTime)
        {
            return new ExtractFunction(dateTime, ExtractType.Second);
        }
        
        public static DateTimeExpression AsExpression(this DateTime dateTime) => dateTime;
    }
}